#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

bool isPrime(int);

bool guess(int, int *, int *); // any even number >= 6 cannot be decomposed into two prime numbers? 

int main(void)
{
    int n;
    int n1, n2;

    printf("Input an even number >= 6: ");

    scanf("%d", &n);


    if (n < 6 || (n % 2 != 0))
    {
        printf("Please input an even number >= 6!\n");
        return -1;
    }
    else
    {
        if (guess(n, &n1, &n2))
        {
            printf("Verified on %d + %d = %d.\n", n1, n2, n);
        }
        else
        {
            printf("Wow, Goldbach guess does not hold on %d!\n", n);
        }

        return 0;
    }
}

bool isPrime(int n)
{
    for (int s = 2; s * s <= n; s ++)
    {
        if (n % s == 0)
        {
            return false;
        }
    }
    return true;
}

bool guess(int n, int *n1, int *n2)
{
    for (int x = 2; x <= n / 2; x ++)
    {
        if (isPrime(x) && isPrime(n - x))
        {
            *n1 = x;
            *n2 = n - x;
            return true;
        }
    }
    return false;
}



